import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/post_request.dart';
import 'package:ls_work/net/response/response_data.dart';

import '../../net/response/devices/device_repair_record_list.dart';

class DeviceRepairRecordViewModel extends BaseListViewModel<DeviceRepairRecordList> {
  final String? id;
  final String? content;
  DeviceRepairRecordViewModel(BuildContext context,{this.content,this.id}) : super(context);

  @override
  Future<List<DeviceRepairRecordList>> requestListData() async {
    var data = await PostRequest.equipmentRepairRecord(id, content, pageLength, page);
    if("0"==data['code'].toString()){
      var bean = ResponseBean.fromJson(data);
      return ((bean.data['rows'] as List?)??[]).map((e) => DeviceRepairRecordList.fromJson(e)).toList();
    }else{
      throw data['msg'];
    }
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }
}
